package com.zpark.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zpark.entity.Person;
import com.zpark.mapper.IPersonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @PackageName: com.zpark.service
 * @ClassName: PersonServiceImpl
 * @Description:
 * @author: RZS
 * @date: 2024/4/30  12:07
 */
@Service
public class PersonServiceImpl implements IPersonService{

    @Autowired
    private IPersonMapper personMapper;

    @Override
    public PageInfo<List<Person>> findLimit(Integer startPage, Integer num) {
        /**
         *      在执行分页查询语句前执行PageHelper.startPage(page, size)方法
         * 即可实现分页查询。
         * startPage(起始页码, 每页显示数量)
         */
        // 开启分页功能，设置分页参数; pageNum:页码, pageSize:每页大小
        PageHelper.startPage(startPage, num);

        // 调用持久层接口查询数据
        List<Person> lists = personMapper.selectList(null);

        return new PageInfo(lists);
    }
}
